package com.yunhe.control;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.yunhe.bean.Admin;
import com.yunhe.service.AdminService;

/**
 * Servlet implementation class AdminSelect
 */
@WebServlet("/adminselect")
public class AdminSelect extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public AdminSelect() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String name =request.getParameter("username");
		System.out.println(name);
		Admin admin =new Admin();
		admin.setAname(name);
		AdminService adm = new AdminService();
		List <Admin> list =adm.selectAdmin(admin);
		System.out.println(list);
		int zongtiaoshu =1;
		for (Admin admin2 : list) {
			System.out.println(admin2);
		}
		
		//response.sendRedirect("hou/admin-list.jsp");
		request.setAttribute("zongtiaoshu", zongtiaoshu);
		request.setAttribute("list", list);
		request.getRequestDispatcher("hou/admin-list.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	
	}

}
